'''
解法：参考网上已理解
编写一个特定函数并调用，函数中采用特定函数进行文件遍历，和查询特定后缀的文件
'''

import sys
import os


def lm_find_files(path, target, result):
    files = os.listdir(path);
    for f in files:
        npath = path + '/' + f
        if (os.path.isfile(npath)):
            if (os.path.splitext(npath)[1] == target):
                result.append(npath)
        if (os.path.isdir(npath)):
            if (f[0] == '.'):
                pass
            else:
                lm_find_files(npath, target, result)
    return result


def main(argv=None):
    result = []
    lm_find_files("C:\\", ".doc", result)
    print(result)


if __name__ == "__main__":
    sys.exit(main())
